<?php

require_once 'model/idiomas.php';

abstract class ActIdiomas extends mIdiomas {
	
	protected $sqlInsert = "insert into idiomas (nome_idioma) values ('%s')";
	protected $sqlDelete = "delete from idiomas where cod_idioma = '%s'";
	protected $sqlUpdate = "update idiomas set nome_idioma='%s' where cod_idioma='%s'";
	protected $sqlSelect = "select * from idiomas %s %s";
	
	
	public function load(){
		$rs = $this->select(sprintf("where cod_idioma = %s",$this->getCodigoIdioma()));
		$this->setCodIdioma($rs[0]['cod_idioma']);
		$this->setNomeIdioma($rs[0]['nome_idioma']);
		return $this;
	}
	
	
	public function insert(){
		$sql = sprintf($this->sqlInsert,
					   $this->getNomeIdioma()
					  );
		return $this->RunQuery($sql);
	}
	
	public function delete (){
		$sql = sprintf($this->sqlDelete,
					   $this->getCodigoIdioma()
					  );
		return $this->RunQuery($sql);
	}
	
	public function update(){
		$sql = sprintf($this->sqlUpdate,
					   $this->getNomeIdioma(),
					   $this->getCodigoIdioma()
					  );
		return $this->RunQuery($sql);
	}
	
	public function select($where = '', $oder=''){
		$sql = sprintf($this->sqlSelect,
						$where,
						$oder
					   );
		return $this->RunSelect($sql);			   
	}
}
?>